<?php
//反查订单的权限 目前只有北京旅游网
$vcode_saccount = array(502140);





function additional_h($order){
	$series = (string)$order['mainOrder']->UUseries;
	$series = unserialize($series);
	$arr = explode('，', $series[6]);
	$round = explode('：', $arr[1]);
	return substr($series[4], 10, 16);
}
?>
<title><?=$v['title']?></title>
<script src="js/ui/PopWindow.js" type="text/javascript"></script>
<!-- <script src="js/zy_Calendar.js" type="text/javascript"></script> --><!-- 旧的已卖出已买到的日历插件-->
<script language="javascript" type="text/javascript" src="http://www.12301.cc/tpl/ui/My97DatePicker/My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="css/default.css"/>
<link rel="stylesheet" type="text/css" href="css/page.css"/>
<link rel="stylesheet" type="text/css" href="css/sell_product.css"/>
<link rel="stylesheet" type="text/css" href="css/buyProduct.css?t=1" />
<link href="js/class/order_ajax/css/searchSuggest.css" type="text/css" rel="stylesheet" />
<script src="js/select2.js"></script> 
<script type="text/javascript" src="js/class/order_ajax/js/order.js"></script>
<script type="text/javascript" src="js/class/order_ajax/js/order_.js"></script>
<script type="text/javascript" src="http://www.12301.cc/js/global/www.12301.cc.global.js"></script>
<link rel="stylesheet" type="text/css" href="css/select2.css">
<div class="rigArea">
	<div class="topTit"><span class="txt"><strong>已<?=($v['from'] == 'sale')? '卖出':'买到'?>的产品</strong></span></div>
	<div id="searchWrap" class="searchWrap">
		<form action="<?=$_SERVER['PHP_SELF']?>" class="report" id="orderSearchForm">
			<input type="hidden" name="act" id="act" />
			<input type="hidden" name="atype" value="<?=$atype?>" />
			<input type="hidden" name="currentPage" value="1"/>
			<input type="hidden" name="status" id="status" value="<?=$_REQUEST['status']?>"/>
			<div class="line linea">
				<span class="lt">订单时间：</span>
				<select class="timeSelect controls" name="xtimes" id="">
					<option <?=$_REQUEST['xtimes']=="1"?"selected":""?> value="1">下单时间</option>
                    <option <?=$_REQUEST['xtimes']=="2"?"selected":""?> value="2">使用有效期</option>
					<option <?=$_REQUEST['xtimes']=="3"?"selected":""?> value="3">完成时间</option>
				</select>
				<input id="op" name="begintime" class="inputText date controls Wdate" type="text" autocomplete="off" onFocus="WdatePicker({dateFmt:'yyyy-M-d H:mm:ss',startDate:'%y-%M-%d 00:00:00',maxDate:'#F{$dp.$D(\'ed\')||\'2020-10-01\'}'})" value="<?=$_REQUEST['begintime']?>"/> 
				<!-- <input type="text" name="begintime" id="op" class="inputText date controls" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$_REQUEST['begintime']?>"/> -->
				<!-- 旧的已卖出已买到的日历插件-->
				<span>至</span>
				<input id="ed" name="endtime" class="inputText date controls Wdate" type="text" autocomplete="off" onFocus="WdatePicker({dateFmt:'yyyy-M-d H:mm:ss',startDate:'%y-%M-%d 23:59:59',minDate:'#F{$dp.$D(\'op\')}',maxDate:'2020-10-01'})" value="<?=$_REQUEST['endtime']?>"/>
				<!-- 旧的已卖出已买到的日历插件-->
				<!-- <input type="text" name="endtime" id="ed" class="inputText date controls"  onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="<?=$_REQUEST['endtime']?>"/> -->
				<span class="sst">汇总时间：</span>
				<a href="#" title="yestoday" class="qc quickDate fqc">昨天</a>
				<a href="#" title="today" class="qc quickDate">今天</a>
				<!-- <a href="#" title="tomorrow" class="qc quickDate">明天</a> -->
				<a href="#" title="week" class="qc quickDate">本周</a>
				<a href="#" title="lastWeek" class="qc quickDate">上周</a>
				<a href="#" title="month" class="qc quickDate">本月</a>
				<a href="#" title="lastMonth" class="qc quickDate">上月</a>
				<i class="calendarBtn c1"></i>
				<i class="calendarBtn c2"></i>
			</div>
			<div class="line lineb">
				<span class="lt">查询条件：</span>
				<select class="condSelect controls" name="tjs" id="condSelect">
					<option <?=$_REQUEST['tjs']=="0"?"selected":""?> value="0">订单号</option>
					<option <?=$_REQUEST['tjs']=="1"?"selected":""?> value="1">产品名称</option>
					<option <?=$_REQUEST['tjs']=="2"?"selected":""?> value="2">取票人姓名</option>
					<option <?=$_REQUEST['tjs']=="3"?"selected":""?> value="3">取票人手机</option>
					<option <?=$_REQUEST['tjs']=="6"?"selected":""?> value="6">远端订单号</option>
                <?if(in_array($_SESSION['saccount'],$vcode_saccount)){?>
                    <option <?=$_REQUEST['tjs']=="7"?"selected":""?> value="7">凭证码</option>
                <?}?>
				</select>
				<input id="condInput" type="text" class="condText controls" value="<?=$_REQUEST['txt']?>" name="txt"/>
				<?$DistorsNames = ($v['from'] == 'sale') ? $disList:$supList;?>
				<?if($_SESSION['sid']==1):?>
				<span class="lt">供应商：</span>
                <?if($_SESSION['sid']==1){//是管理员的情况?>
					<div id="searchSuggest">
                        <?
                        if($_GET['supplier']){
                            $sel_supplier = "select dname from pft_member where id={$_GET['supplier']} limit 1";
                            $GLOBALS['le']->query($sel_supplier);
                            $row_s_dname=$GLOBALS['le']->fetch_assoc();
                        }
                        ?>
						<input type="text" id="suggest_input" autocomplete="off" value="<?=$row_s_dname['dname'] ? $row_s_dname['dname']:点击搜索供应商?>" onfocus="if (value =='点击搜索供应商'){value =''}" onblur="if (value ==''){value='点击搜索供应商'}"/>
						<input type="hidden" name="supplier" id="li_id" value="<?=$_GET['supplier']?>"/>
						<input type="hidden"  id="lid_id" value="0"/>
						<ul id="suggest_ul">
						</ul>
					</div>
                <?}else{?>
				<select class="fenxiaoSelect controls" name="supplier" id="bindList">
					<option value="">请选择供应商</option>
					<?foreach($DistorsNames as $key=> $cn):?>
					<option value="<?=$key?>" <?if($_REQUEST['supplier']==$key)echo 'selected="selected"'?>><?=$cn?></option>
					<?endforeach;}?>
				</select>
				<script>
					$("#bindList").select2({
						placeholder: "Select a State",
						allowClear: true
					});
				</script>
				<?
                endif;
                $_REQUEST['status']=is_array($_REQUEST['status']) ? $_REQUEST['status'] : array();
                $_REQUEST['payinfo']=is_array($_REQUEST['payinfo']) ? $_REQUEST['payinfo'] : array();
				$DistorsNames = ($v['from'] == 'sale') ? $disList:$supList;
                ?>
				<span class="lt"><?=($v['from'] == 'sale')?'分销商':'供应商'?>：</span>
				<!--controls-->
                <?if($_SESSION['sid']==1){//是管理员的情况?>
                 <div id="searchSuggest_a">
                        <?
                        if($_GET['distributor']){
                            $sel_distributor = "select dname from pft_member where id={$_GET['distributor']} limit 1";
                            $GLOBALS['le']->query($sel_distributor);
                            $row_d_dname=$GLOBALS['le']->fetch_assoc();
                        }
                        ?>
						<input type="text" id="suggest_input_a" autocomplete="off" value="<?=$row_d_dname['dname'] ? $row_d_dname['dname']:点击搜索分销商?>"  onfocus="if (value =='点击搜索分销商'){value =''}" onblur="if (value ==''){value='点击搜索分销商'}"/>
						<input type="hidden" name="distributor" id="li_id_a" value="<?=$_GET['distributor']?>"/>
                        
						<input type="hidden" id="lid_id_a" value="1"/>
						<ul id="suggest_ul_a">
						</ul>
				</div>
                <?}else{?>
				<select class="fenxiaoSelect " name="<?=($v['from'] == 'sale')?'distributor':'supplier'?>" id="bindList2">
					<option value="">请选择<?=($v['from'] == 'sale')?'分销商':'供应商'?></option>
					<?foreach($DistorsNames as $key=>$cn):?>
					<option value="<?=$key?>" <?if($_REQUEST['distributor']==$key || ($_REQUEST['supplier']==$key && $_SESSION['memberID']!=1)) echo 'selected="selected"'?>><?=$cn?></option>
					<?endforeach;}?>                    
                    <?/*if($v['from'] == 'sale'){?>
                    <option value="1sanke" <?if($_REQUEST['supplier']=='1sanke')echo 'selected="selected"'?>>散客</option>
                    <?}*/?>
				</select> 
				<script>
					$("#bindList2").select2({
						placeholder: "Select a State",
						allowClear: true
					});
				</script>
			</div>
            <div id='vcode_landname' class="line linec" style='display:<?=$_REQUEST['tjs']=="7"?"block":"none"?>;margin-bottom:8px'>
                <span class="lt">景区名称：</span>
                <input name='vcode_landname' class='condText controls' style='width:300px' value='<?=$_REQUEST['vcode_landname']?>'/>
            </div>
			<div class="line linec setPosition">
				<span class="lt" style="position: absolute;left: 5px; top: 8px;">订单状态：</span>
                <div class="radioBox">
				<label for="labcheckaa"><input type="checkbox" class="checkbox" name="status[]" value="0" <?=(in_array(0,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">未使用</span></label>
				<label for="labcheckab"><input type="checkbox" class="checkbox" name="status[]" value="1" <?=(in_array(1,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">已使用</span></label>
				<label for="labcheckac"><input type="checkbox" class="checkbox" name="status[]" value="2" <?=(in_array(2,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">已过期</span></label>
				<label for="labcheckad"><input type="checkbox" class="checkbox" name="status[]" value="3" <?=(in_array(3,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">已取消</span></label>
            <?if($_SESSION['sdtype']==9){?>
                <label for="labcheckad"><input type="checkbox" class="checkbox" name="status[]" value="4" <?=(in_array(4,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">凭证码被替代</span></label>
                <label for="labcheckad"><input type="checkbox" class="checkbox" name="status[]" value="5" <?=(in_array(5,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">被终端修改</span></label>
                <label for="labcheckad"><input type="checkbox" class="checkbox" name="status[]" value="6" <?=(in_array(6,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">被终端撤销</span></label>
                <label for="labcheckad"><input type="checkbox" class="checkbox" name="status[]" value="7" <?=(in_array(7,$_REQUEST['status']))?"checked":""?>/><span class="checkboxT">部分使用</span></label>
            <?}?>
            </div>
			</div>
			<div class="line linec setPosition">
				<span class="lt" style="position: absolute;left: 5px; top: 8px;">支付方式：</span>
                <div class="radioBox">
                <label for="labcheckba"><input type="radio" name="payinfo[]" <?=(in_array(0,$_REQUEST['payinfo']))?"checked":""?> value="0" class="checkbox"/><span>帐户余额</span></label>
                <label for="labcheckbb"><input type="radio" name="payinfo[]" <?=(in_array(1,$_REQUEST['payinfo']))?"checked":""?> value="1" class="checkbox"/><span>支付宝</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(2,$_REQUEST['payinfo']))?"checked":""?> value="2" class="checkbox"/><span>授信支付</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(3,$_REQUEST['payinfo']))?"checked":""?> value="3" class="checkbox"/><span>自供自销</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(4,$_REQUEST['payinfo']))?"checked":""?> value="4" class="checkbox"/><span>现场支付</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(5,$_REQUEST['payinfo']))?"checked":""?> value="5" class="checkbox"/><span>微信支付</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(7,$_REQUEST['payinfo']))?"checked":""?> value="7" class="checkbox"/><span>银联支付</span></label>
                <label for="labcheckbc"><input type="radio" name="payinfo[]" <?=(in_array(8,$_REQUEST['payinfo']))?"checked":""?> value="8" class="checkbox"/><span>环迅支付</span></label>
                </div>
            </div>
            <div class="line linec setPosition">
				<span class="lt" style="position: absolute;left: 5px; top: 4px; width: 60px;">支付状态：</span>
                <div class="radioBox">
                    <label><input type="radio" name="pays" checked="checked" value=""/>不限</label>
                    <label><input type="radio" name="pays" value="1" <?=($_GET['pays']==1)?"checked":""?>/>已支付</label>
                    <label><input type="radio" name="pays" value="2" <?=($_GET['pays']==2)?"checked":""?>/>未支付</label>
                    <label><input type="radio" name="pays" value="0" <?=($_GET['pays']==='0')?"checked":""?>/>现场支付</label>
                </div>
            </div>
			<div class="formBtnW">
				<input id="queryProductBtn" type="submit" value="查 询" class="queryBtn searchBtn" />
				<a href="javascript:void(0);" class="dcexcleBtn searchBtn" id="excel">导出excle</a>
			</div>
		</form>
	</div>
	<?php if(in_array($_SESSION['sid'],$showTotalOrder) && $time_mark):?>
<!--        && $_GET['txt']==''&&$_GET['supplier']==''&&$_GET['distributor']==''-->
        <div id="totalSumW" class="totalSumW" >
            <p class="thisPage" style="/*display:none*/"><span class="span1">统计所有(含转分销)：</span>&nbsp;&nbsp;&nbsp;<span class="span1">订单数<i class="i ia green" id="total_onum"><?=$count_total[0]?></i>单</span><span>数 量<i class="i ib red" id="total_tnum"><?=$count_total[1]?></i></span><span>总金额<i class="i ic orange"  id="total_mnum"><?       //防止金额太小 出现 E-5万元 之类的字
                        if($count_total[2]<100)
                            echo ($count_total[2]/100).'</i>';
                        else
                            echo ($count_total[2]/1000000).'</i>万';
                        ?>元</span>&nbsp&nbsp&nbsp&nbsp&nbsp金额为订单最后一级转分销的金额</p>
            <p class="allPage" style="display:none;"><button id="getAllpagemonery">统计所有</button></p>
        </div>
        <?if( ($_SESSION['sid']==1) && !$_GET['txt'] && !$_GET['supplier'] && !$_GET['distributor'] && !$_GET['status'] && !$_GET['payinfo'] && $time_mark){?>
        <div id="totalSumW" class="totalSumW" >
            <p class="thisPage" style="/*display:none*/"><span class="span1">统计所有(不含转分销)：</span><span class="span1">订单数<i class="i ia green" id="total_onum"><?=$count_total_lastLevel[0]?></i>单</span><span>数 量<i class="i ib red" id="total_tnum"><?=$count_total_lastLevel[1]?></i></span><span>总金额<i class="i ic orange"  id="total_mnum"><?
                        if($count_total_lastLevel[2]<100)
                            echo ($count_total_lastLevel[2]/100).'</i>';
                        else
                            echo ($count_total_lastLevel[2]/1000000).'</i>万';
                        ?>元</span></p>
            <p class="allPage" style="display:none;"><button id="getAllpagemonery">统计所有</button></p>
        </div>
        <?}?>
	<?php endif;?>
	<table id="listTable" class="proTable fixed">
		<thead id="proTableHead">
			<th class="col_1">订单号</th>
			<th class="col_2">产品信息</th>
			<th class="col_3">取票人信息</th>
			<? echo  ($v['from']=='buy') ? '<th class="col_4">供应商</th>':'<th class="col_4">分销商</th>';?>
			<th class="col_5">支付方式</th>
			<th class="col_6">订单状态</th>
			<th class="col_7">总金额</th>
			<th class="col_8">操作</th>
		</thead>
		<tbody>
			<!-- 第1个产品 -->
			<?
			foreach($r as $row):
				$childNum = count($row['childOrder']);

			?>
			<tr class="listHead">
				<td colspan="8">
					<div>
						<a href="scenicDetail.html?lid=<?=(string)$row['mainOrder']->UUlid?>" title="<?=(string)$row['mainOrder']->UUltitle?>" class="title" target="_blank"><?=(string)$row['mainOrder']->UUltitle?></a>
						<p class="rt">
							<span class="span">下单时间：<?=(string)$row['mainOrder']->UUordertime?></span>
							<span class="span">有效期：<?=(string)$row['mainOrder']->UUbegintime?> 至 <?
                                if((string)$row['mainOrder']->UUp_type == 'F') {
                                    //套票的话要去获取子票的时间
                                    $or    = new OrderRecord((int)$row['mainOrder']->UUordernum,$s);
                                    $child_row = $or->info();

                                    echo $child_row['childOrder']? (string)$child_row['childOrder'][0]->UUendtime :(string)$row['mainOrder']->UUendtime;
                                }else if(((string)$row['mainOrder']->UUp_type == 'C')){
                                    $or    = new OrderRecord((int)$row['mainOrder']->UUordernum,$s);
                                    $child_row = $or->info();
                                    if(count($child_row['childOrder'])) {
                                        echo date('Y-m-d',strtotime((string)$child_row['childOrder'][0]->UUendtime)+86400);}
                                    else
                                        echo date('Y-m-d',strtotime((string)$row['mainOrder']->UUendtime)+86400);
                                }
                                else echo $row['mainOrder']->UUendtime ;
                                ?></span>
							<span class="span span3">验证时间：<?=(string)$row['mainOrder']->UUdtime!="0000-00-00 00:00:00"?(string)$row['mainOrder']->UUdtime:"未验证"?></span>
						</p>
					</div>
				</td>
			</tr>
			<tr class="listBody <?if(!$childNum)echo 'borderBottom';?>" data-ordernum="<?=$row['mainOrder']->UUordernum?>">
				<td class="col_1 col" rowspan="<?=$childNum + 1?>">
				<?if((string)$row['mainOrder']->UUp_type=='F'):?>
				<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
				<?else:?>
					<?if(isMainOrder($row['mainOrder']->UUconcat_id)):?>
					<a target="_blank" href="orderView
					.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>&pack=1" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
					<?else:?>
					<a target="_blank" href="orderView.html?from=<?=$v['from']?>&ordernum=<?=$row['mainOrder']->UUordernum?>&type=<?=$row['mainOrder']->UUp_type?>" class="ordernb"><?=(string)$row['mainOrder']->UUordernum?></a>
					<?endif;?>
				<?endif;?>
                <?if((string)$row['mainOrder']->UUremotenum){?>
				<span class="f_orderNum"><?=(string)$row['mainOrder']->UUremotenum?></span>
				<?}?>
				</td>
				<td class="col_2 col">
				
				【<?=(string)$row['mainOrder']->UUttitle?>】<span class="numPrice"> *
                        <i id="<?=(int)$row['mainOrder']->UUordernum.'_'.(int)$row['mainOrder']->UUtid?>">
                            <?=(int)$row['mainOrder']->UUtnum?></i> 张 * &yen;
                        <i><?=(int)$row['mainOrder']->UUtprice/100?></i></span>
				<?if((string)$row['mainOrder']->UUp_type=='H'):?>
				<br/>演出时间：<?echo additional_h($row)?>
				<?endif;?>
				</td>
				<td class="col_3 col" rowspan="<?=$childNum + 1?>">
					<p class="name"><?=(string)$row['mainOrder']->UUordername?></p>
					<p class="tell"><?=(string)$row['mainOrder']->UUordertel?></p>
				</td>
				<?if($showDtr){?>
				<td class="col_4 col" rowspan="<?=$childNum + 1?>">
				<?
                    if($_SESSION['dtype']==2){// 直接供应方（景区）只看到供应商
                        echo $anames[(int)$row['mainOrder']->UUsellid]?
                        $anames[(int)$row['mainOrder']->UUsellid]:(string)$row['mainOrder']->UUdname;
                    }elseif($v['from']=='buy'){// 已买到
						echo $anames[(int)$row['mainOrder']->UUsellid]?
						$anames[(int)$row['mainOrder']->UUsellid]:(string)$row['mainOrder']->UUdname;
					}else{// 已卖出
						echo $fnames[(int)$row['mainOrder']->UUbuyid]?
						$fnames[(int)$row['mainOrder']->UUbuyid]:(string)$row['mainOrder']->UUdname;
					}
                    if(substr((string)$row['mainOrder']->UUremotenum,0,2)=='MO'){
                        echo "<br/><i style='color: orange'>(微信渠道)</i>";
                    }
				?>
				</td>
				<?}?>
				<td class="col_5 col" rowspan="<?=$childNum + 1?>">
					<?=OrderRecord::$paymodeT[(string)$row['mainOrder']->UUpmode]?>
					<?if($row['mainOrder']->UUordermode==9){?>
						</br><em class="fuchsia">(现场购票)</em>
					<?}elseif($row['mainOrder']->UUordermode!=0){?>
						</br><em class="fuchsia">(散客预定)</em>
					<?}?>

				</td>
				<td class="col_6 col" rowspan="<?=$childNum + 1?>">
				<span rowspan="<?=$row['totalOrder']?>">
                    <p>
                        <?
                        if((string)$row['mainOrder']->UUp_type == 'F' && (int)$row['mainOrder']->UUstatus == 2){//如果套票并且已过期 去查询子票是否真的过期
                            //如果子票未过期 则未使用 如果子票已过期 那就真的过期了
                            $row['mainOrder']->UUstatus = (int)$child_row['childOrder'][0]->UUstatus == 2? 2 : 0;

                        }
                        if((string)$row['mainOrder']->UUpaystatus==1){
                            echo $uuStatus[(string)$row['mainOrder']->UUstatus];
                        }elseif((string)$row['mainOrder']->UUstatus==3 && (string)$row['mainOrder']->UUpaystatus==2){
                            echo $uuStatus[(string)$row['mainOrder']->UUstatus];
                            //echo '<br/><span style="color:orange;">(未支付)</span>';
                        }else{
                            echo $uuStatus[(string)$row['mainOrder']->UUstatus];
                        }
                        ?>
            
                        <?if((string)$row['mainOrder']->UUstatus==2 && (string)$row['mainOrder']->UUpaystatus==2) echo '<br/><span style="color:red;">(未支付)</span>';?>
                    </p>

                    <p class="green">
					<?if($row['mainOrder']->UUstatus==0){?>
					<?=OrderRecord::$paystatusT[(string)$row['mainOrder']->UUpaystatus]?>
					<?}?>
					</p>
				</td>
				<td class="col_7 col" rowspan="<?=$childNum + 1?>">

					<?if(!isMainOrder($row['mainOrder']->UUconcat_id)):?>
					合计<span class="totalPrice">&yen;<i><?=((int)$row['mainOrder']->UUtprice*(int)$row['mainOrder']->UUtnum)/100?></i></span>
					<?else:?>
					<?
						$total = 0;
						foreach($row['childOrder'] as $cr){
							// $total = $total + (string)$cr['totalPrice']/100 ;
							$total = $total + ((int)$cr['mainOrder']->UUtprice*(int)$cr['mainOrder']->UUtnum)/100;
						}
						$total += ((int)$row['mainOrder']->UUtprice*(int)$row['mainOrder']->UUtnum)/100;
					?>
					合计<span class="totalPrice">&yen;<i><?=$total?></i></span>
					<?endif;?>
					
				</td>
				<td class="col_8 col" rowspan="<?=$childNum + 1?>">
				<?
					// 订单号
					$order = (string)$row['mainOrder']->UUordernum;
					//if(!isMainOrder($row['mainOrder']->UUconcat_id)){// 不是联票
                $v['from'] = strpos($_SERVER['SCRIPT_FILENAME'],'/buyProduct.html')!==false ?'buy':'sale';
						//查看
						$view='orderView.html?from='.$v['from'].'&ordernum=';
						$view.= $order.'&type='.$row['mainOrder']->UUp_type;
						if((string)$row['mainOrder']->UUp_type=='F' || isMainOrder($row['mainOrder']->UUconcat_id)) 
                            $view.='&pack=1';
                        if($_SESSION['sid']==1)//管理员时 链接带上购买者id 用来区分显示不同价格
                            $view.= '&aid='.(int)$row['mainOrder']->UUsellid;
						echo '<a target="_blank" href="'.$view.'">查看</a>';
						
						//支付
						if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderAlipay"))
							echo '<a target="_blank" class="payBtn" href="alipayOrder.html?ordernum='.$order.'">支付</a>';
						
						// **********************************
						if((string)$row['mainOrder']->UUifpack!=2){// 不是子票的才显示取消、修改、重发
							// 取消
                            //2015-07-02 讨论后决定只有管理员能取消订单 并且所有取消的订单都退款  --zax

							if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderCancel"))
								echo '<a data-ordernum="'.$row['mainOrder']->UUordernum.'" act="cancel" class="orderHandle cancelBtn" href="call/handle.php?from=order_cancel&ordernum='.$order.'">取消</a>';
							// 修改
							if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderAlter") ){
									$concat='';
                                    $data_ticket= '';
                                    $data_ticket = '【'.$row['mainOrder']->UUttitle.'】|'.$row['mainOrder']->UUtnum.'|'.(int)$row['mainOrder']->UUtid;//拼数据 为了前端好取 zax
                                    if(count($row['childOrder'])){
                                        foreach($row['childOrder'] as $val){
                                            $data_ticket .= '&【'.(string)$val['mainOrder']->UUttitle.'】|'.(int)$val['mainOrder']->UUtnum.'|'.(int)$val['mainOrder']->UUtid;
                                        }
                                    }
									if(isMainOrder($row['mainOrder']->UUconcat_id)){
									echo '<a class="alter modifyBtn" data-title="'.$row['mainOrder']->UUltitle.'" data-ticket="'.$data_ticket.'" data-ordernum="'.$row['mainOrder']->UUordernum.'" href="call/handle.php?from=orderAlterHtml&ordernum='.$order.'&concat=1">修改</a>';
									}else{
									echo '<a class="alter modifyBtn" data-title="'.$row['mainOrder']->UUltitle.'" data-ticket="'.$data_ticket.'" data-ordernum="'.$row['mainOrder']->UUordernum.'" href="call/handle.php?from=orderAlterHtml&ordernum='.$order.'">修改</a>';
									}
                            }
                        }
                if(OrderRecord::orderChkAuth($row['mainOrder'])){
                    $code=$row['mainOrder']->UUcode;
                    echo '<a target="_blank" class="ternialBtn" href="terminal_chk.html?sid='.$row['mainOrder']->UUlid.'&chk='.$code.'">验证</a>';
                }
                // 重发
                if(OrderRecord::orderOperAuth($row,$memberID,$account,"orderResend") && (string)$row['mainOrder']->UUifpack!=2)
                    echo '<a act="cancel" class="resend resendBtn" href="call/handle.php?from=order_resend&&ordernum='.$order.'">重发短信</a>';


                if(strpos($_SERVER['SCRIPT_FILENAME'],'/buyProduct.html')!==false){
                    echo <<<HTML
                        <a target="_blank" class="ternialBtn" href="http://www.12301.cc/productOrder.html?pid={$row['mainOrder']->UUpid}&aid={$row['mainOrder']->UUsellid}">再次购买</a>
HTML;

                }


						// *********************************
					// }elseif(isMainOrder($row['mainOrder']->UUconcat_id)){//联票订单联票显示方式
						// echo '<span>复票订单<span><br/>';
						// echo '<a href="orderView.html?from='.$v['from'].'&ordernum='.$order.'&type='.$row['mainOrder']->UUp_type.'&pack=1" target="_blank">查看详细</a>';
					// }
				?>		
				<?if($_SESSION['dtype']==2 && in_array($_SESSION['account'],$arr_salerid)):?>
					<span><?=$row['mainOrder']->UUcode?></span>
				<?endif;?>
				</td>
			</tr>
			<?foreach($row['childOrder'] as $cr):?>
			<tr class="listBody borderBottom borderTop" data-ordernum="<?=$row['mainOrder']->UUordernum?>">
				<td class="col_2 col">
					【<?=(string)$cr['mainOrder']->UUttitle?>】
					<span class="numPrice"> *
                        <i id="<?=(int)$row['mainOrder']->UUordernum.'_'.(int)$cr['mainOrder']->UUtid?>"><?=(string)$cr['mainOrder']->UUtnum?></i>
                        张 * &yen;<i><?=(string)$cr['mainOrder']->UUtprice/100?></i></span>
				</td>
			</tr>
			<?endforeach;//子票?>
			<tr class="marTop"><td colspan="8"></td></tr>
			<?endforeach;?>
		</tbody>
	</table>
	<?page($count,$currentPage,$pageSize,$order,$by);?>
	<style>.whichPageWrap{ display:block;}</style>
</div>
<div id="theadCopy" class="theadCopy">
	<ul>
		<li>订单号</li>
		<li style="text-align: left; padding-left: 10px;">产品信息</li>
		<li style="text-align: left; padding-left: 10px;">取票人信息</li>
		<? echo  ($v['from']=='buy') ? '<li style="text-align: left; padding-left: 15px;">供应商</li>':'<li style="text-align: left; padding-left: 15px;">分销商</li>';?>
		<li>支付方式</li>
		<li>订单状态</li>
		<li>总金额</li>
		<li>操作</li>
	</ul>
</div>
<script type="text/javascript" src="http://wx.12301.cc/public/js/common/class.js"></script>
<? include("tpl/dialog/dialog.html");?>
<script type="text/javascript" src="js/buyProduct.js"></script>
<script type="text/javascript" src="js/plugin/date/moment.min.js"></script>
<script id="modTicDiaTpl" type="text/template">
    <div class="modTicketDialogCon">
        <p class="tip" style="padding:5px 0 0 23px; color:red">* 只能在原票数基础上减少票数</p>
        <form id="ticModForm" action="" method="post">
            <input id="modifyTicket_ordernum_hidInp" name="ordernum" value="" type="hidden"/>
            <ul id="ticModListUl" class="tlist"><%=ticketList%></ul>
        </form>
		<div class="btnGroup"><a class="btn modify modifyBtn" href="#">修改</a><a class="btn cannel cannelModifyBtn" href="#">取消</a></div>
	</div>
</script>
<script id="modTicDiaList" type="text/template">
    <li class="ticketLi">
        <span class="tname"><%=tname%></span>
        <span class="countWrap">
             <input class="numInp" <%=readonly%> type="text" data-tid="<%=tid%>" name="tids[<%=tid%>]" id="" data-max="<%=tnum%>" data-min="1" value="<%=tnum%>"/>
             <% if(readonly==""){ %>
                <a href="javascript:void(0)" class="minuBtn numBtn"><i class="iconfont">&#xe67a;</i></a>
             <% }else{ %>
                 <a href="javascript:void(0)" class="minuBtn numBtn disable"><i class="iconfont">&#xe67a;</i></a>
             <% } %>
             <a href="javascript:void(0)" class="addBtn numBtn disable"><i class="iconfont">&#xe653;</i></a>
        </span>
    </li>
</script>
<style type="text/css">
    #PFT_dialogWrap .dialog-con{ padding:0;}
    #ticModListUl{ padding:5px 0 5px 0;}
    #ticModListUl li{ position:relative; overflow:hidden; padding:12px 20px 12px 20px; border-bottom:1px solid #dbdbdb}
    #ticModListUl li:last-child{ border-bottom:0 none}
    #ticModListUl .tname{ display:block; float:left; width:120px; height:36px; line-height:36px; overflow:hidden;}
    #ticModListUl .countWrap{ display:block; float:left; position:relative; width:50px; padding:0 35px; margin-top:1px}
    #ticModListUl .countWrap .numInp{ display:block; height:32px; width:100%; padding:0; line-height:22px; border:1px solid #dbdbdb; border-radius:3px; text-align:center; background:#fff;
        -webkit-box-shadow:inset 0px 1px 1px rgba(0,0,0,.075);
        -moz-box-shadow:inset 0px 1px 1px rgba(0,0,0,.075);
        -ms-box-shadow:inset 0px 1px 1px rgba(0,0,0,.075);
        -o-box-shadow:inset 0px 1px 1px rgba(0,0,0,.075);
        box-shadow:inset 0px 1px 1px rgba(0,0,0,.075);
        line-height:32px\9;
    }
    #ticModListUl .countWrap .numBtn{ position:absolute; top:1px; display:block; width:32px; height:32px; line-height:32px; text-align:center; color:#fff; background:#2a98da; border-radius:3px;}
    #ticModListUl .countWrap .numBtn .iconfont{ font-size:12px}
    #ticModListUl .countWrap .numBtn:hover{ text-decoration:none}
    #ticModListUl .countWrap .numBtn.addBtn{ right:-2px;}
    #ticModListUl .countWrap .numBtn.minuBtn{ left:0;}
    #ticModListUl .countWrap .numBtn.disable{ background:#dbdbdb; color#fff; cursor:default}
    .modTicketDialogCon .btnGroup{ border-top:1px solid #dbdbdb; text-align:center; background:#fcfcfc}
    .modTicketDialogCon .btnGroup .btn{ display:inline-block; width:50%; height:45px; line-height:45px; color:#2a98da; font-size:14px; border-left:1px solid #dbdbdb}
    .modTicketDialogCon .btnGroup .btn:hover{ text-decoration:none; background:#f7f7f7}
    .modTicketDialogCon .btnGroup .btn:first-child{ border-left:0 none; margin-left:-1px}

</style>
<script type="text/javascript">

    //表格操作： 取消订单 重发短信 修改订单
    var TableList = RichBase.extend({
        statics : {
            dialog : null,
            isPositiveNum : function(count){
                count = String(count);
                var type="^[0-9]*[1-9][0-9]*$";
                var re = new RegExp(type);
                if(count.match(re) == null){
                    return false;
                }
                return true;
            }
        },
        EVENTS : {
            "click" : {
                ".orderHandle" : "cancelOrder",
                ".resend" : "resendMsg",
                ".alter" : "openDialog"
            }
        },
        init : function(opt){
            this.tableContainer = opt.container;
        },
        //取消订单
        cancelOrder : function(that,e){
            e.preventDefault();
            var tarBtn = $(e.currentTarget);
            var result = confirm("确定要取消该订单？");
            if(!result) return false;
            var success = function(){
                var ordernum = tarBtn.attr("data-ordernum");
                PFT_GLOBAL.U.Alert("success",'<p style="width:120px;">取消成功</p>');
                tarBtn.parent().siblings('.col_6').html("<em class='red'>已取消</em>");
                var trs = $("#listTable").children("tbody").children("[data-ordernum="+ordernum+"]");
                trs.addClass("disable");
                tarBtn.remove();
            };
            $.ajax({
                url : tarBtn.attr("href"),
                dataType : "json",
                beforeSend : function(){
                    tarBtn.html("正在取消...");
                },
                success : function(data){
                    tarBtn.html("取消");
                    if(data.outcome==1){
                        success();
                    }else{
                        var txt = data.msg || "";
                        PFT_GLOBAL.U.Alert("fail",'<p style="width:400px;">取消失败 '+txt+'</p>');
                    }
                },
                error : function(){
                    tarBtn.html("取消");
                }
            })
        },
        //重发短信
        resendMsg : function(that,e){
            e.preventDefault();
            var that = this;
            var tarBtn = $(e.currentTarget);
            if(!confirm("确定要重发短信？")) return false;
            $.ajax({
                url : tarBtn.attr("href"),
                dataType : "json",
                beforeSend : function(){
                    tarBtn.text("正在重发...")
                },
                success : function(data){
                    tarBtn.text("重发");
                    if(data.outcome==1){
                        PFT_GLOBAL.U.Alert("success",'<p style="width:120px;">重发成功</p>');
                    }else{
                        var txt = data.msg || "";
                        alert(txt);
                    }
                },
                error : function(){
                    tarBtn.text("重发")
                }
            })
            return false;
        },
        //修改票数
        modifyTicket : function(){
            var that = this;
            var tarBtn = this.statics.modifyBtn;
            var modifyData = $("#ticModForm").serialize();
            $.ajax({
                url : "call/handle.php?from=order_alter",
                type : "post",
                dataType : "json",
                data : modifyData,
                beforeSend : function(){
                    tarBtn.text("正在修改..");
                },
                success:function(data){
                    tarBtn.text("修改");
                    if(data.outcome==1){
                        PFT_GLOBAL.U.Alert("success",'<p style="width:120px;">修改成功</p>');
                        var ordernum = $("#modifyTicket_ordernum_hidInp").val();
                        $("#ticModForm").find(".numInp").each(function(){
                            var tarInp = $(this);
                            var tid = tarInp.attr("data-tid");
                            var tnum = tarInp.val();
                            $("#"+ordernum+"_"+tid).text(tnum);
                        })
                        var tr = $("#listTable").children("tbody").children("[data-ordernum="+ordernum+"]").first();
                        var total = tr.find(".col_7 .totalPrice i");
                        data.price && total.text(data.price);
                        var result = [];
                        $("#ticModListUl").children().each(function(){
                            var li = $(this);
                            var tname = li.children(".tname").text();
                            var inp = li.find(".numInp");
                            var tid = inp.attr("data-tid");
                            var num = inp.val();
                            result.push(tname+"|"+num+"|"+tid);
                        })
                        that.statics.modifyBtn.attr("data-ticket",result.join("&"));
                    }else{
                        var txt = data.msg || "";
                        alert(txt);
                    }
                },
                error : function(){
                    PFT_GLOBAL.U.Alert("fail",'<p style="width:200px;">修改失败，请稍后重试</p>');
                }
            })
        },
        initDialog : function(con){
            var self = this;
            this.statics.dialog = new PFT.Dialog({
                content : con,
                EVENTS : {
                    "click" : {
                        //确认修改
                        ".modTicketDialogCon .modifyBtn" : function(that,e){
                            e.preventDefault();
                            that.close();
                            self.modifyTicket();
                        },
                        //取消修改
                        ".modTicketDialogCon .cannelModifyBtn" : function(that,e){
                            e.preventDefault();
                            that.close();
                        },
                        //减票数
                        ".modTicketDialogCon .minuBtn" : function(that,e){
                            var tarBtn = $(e.currentTarget);
                            if(tarBtn.hasClass("disable")) return false;
                            var tarInp = tarBtn.parent().children(".numInp");
                            var val = tarInp.val();
                            var min = tarInp.attr("data-min");
                            var addBtn = tarBtn.parent().children(".addBtn");
                            val--;
                            addBtn.removeClass("disable");
                            if(val>=min){
                                tarInp.val(val);
                                val==min ? tarBtn.addClass("disable") : tarBtn.removeClass("disable");
                            }else{
                                tarBtn.addClass("disable");
                            }
                        },
                        //加票数
                        ".modTicketDialogCon .addBtn" : function(that,e){
                            var tarBtn = $(e.currentTarget);
                            if(tarBtn.hasClass("disable")) return false;
                            var tarInp = tarBtn.parent().children(".numInp");
                            var val = tarInp.val();
                            var max = tarInp.attr("data-max");
                            var minuBtn =  tarBtn.parent().children(".minuBtn");
                            val++;
                            minuBtn.removeClass("disable");
                            if(val<=max){
                                tarInp.val(val);
                                val==max ? tarBtn.addClass("disable") : tarBtn.removeClass("disable");
                            }else{
                                tarBtn.addClass("disable");
                            }
                        }
                    },
                    "focus" : {
                        ".modTicketDialogCon .numInp" : function(that,e){
                            var tarInp = $(e.currentTarget);
                            tarInp.attr("data-lastval",tarInp.val());
                        }
                    },
                    "blur" : {
                        ".modTicketDialogCon .numInp" : function(that,e){
                            var tarInp = $(e.currentTarget);
                            var val = tarInp.val() * 1;
                            var lastVal = tarInp.attr("data-lastval") * 1;
                            var maxVal = tarInp.attr("data-max") * 1;
                            var minVal = tarInp.attr("data-min") * 1;
                            if(!self.statics.isPositiveNum(val)){
                                tarInp.val(lastVal);
                            }else if(val<minVal){
                                tarInp.val(minVal);
                            }else if(val>maxVal){
                                tarInp.val(maxVal);
                            }
                        }
                    }
                }
            });
        },
        //点击弹出票修改dialog
        openDialog : function(that,e){
            e.preventDefault();
            var tarBtn = $(e.currentTarget);
            var title = tarBtn.attr("data-title");
            var api = tarBtn.attr("href");
            var ordernum = tarBtn.attr("data-ordernum");
            var tickets = tarBtn.attr("data-ticket").split("&");
            var dialogTpl = $("#modTicDiaTpl").html();
            var con = that.parseTemplate(dialogTpl,{ticketList:""});
            var listTpl = $("#modTicDiaList").html();
            if(!that.statics.dialog) that.initDialog(con);
            that.statics.dialog.open({
                title : title,
                content : con,
                offset : -100,
                onBeforeOpen : function(){
                    var list = "";
                    for(var i in tickets){
                        var t = tickets[i].split("|");
                        var tname = t[0];
                        var tnum = t[1];
                        var tid = t[2];
                        var readonly = tnum==1 ? "readonly" : "";
                        list += that.parseTemplate(listTpl,{
                            tname : tname,
                            tnum : tnum,
                            tid : tid,
                            readonly : readonly
                        });
                    }
                    that.statics.modifyBtn = tarBtn;
                    $("#modifyTicket_ordernum_hidInp").val(ordernum);
                    $("#ticModListUl").html(list);
                    $("#ticModForm").attr("action",api);
                }
            })
        }
    });

    $(function(){
        new TableList({ container:$("#listTable")})
    })
</script>
<script type="text/javascript">

    $(".mcul li a").click(function(){
        $("#status").val($(this).attr("status"));
        $(".sbtn").click();
        return false;
    })

    $("#excel").click(function(){

        $("#act").val("Export");
        $("form.report").submit();
        $("#act").val("");
    });
    $(".checkbox").click(function(){
        if($(this).attr('data-check')=='1'){
            $(this).attr('checked',false);
            $(this).attr('data-check','0')
            return;
        }
        var v = $(this);
        $(".checkbox").each(function(i){
            $(this).attr('data-check','0');
        })
        v.attr('data-check','1');
    });

    $('#condSelect').change(function(){
        if ($('#condSelect').val()=='7'){
            $('#vcode_landname').show();
        }else{
            $('#vcode_landname').hide();
        }
    })
</script>

